package com.ruoyi.web.controller.customerPhoto;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CustomerPhoto;
import com.ruoyi.system.service.ICustomerPhotoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客照关系Controller
 * 
 * @author Eugene
 * @date 2023-04-15
 */
@Api(tags = "客照关系")
@RestController
@RequestMapping("/CustomerPhoto/photo")
public class CustomerPhotoController extends BaseController
{
    @Autowired
    private ICustomerPhotoService customerPhotoService;

    /**
     * 查询客照关系列表
     */
    @ApiOperation("查询客照关系列表")
    @PreAuthorize("@ss.hasPermi('CustomerPhoto:photo:list')")
    @GetMapping("/list")
    public TableDataInfo list(CustomerPhoto customerPhoto)
    {
        startPage();
        List<CustomerPhoto> list = customerPhotoService.selectCustomerPhotoList(customerPhoto);
        return getDataTable(list);
    }

    /**
     * 导出客照关系列表
     */
    @PreAuthorize("@ss.hasPermi('CustomerPhoto:photo:export')")
    @Log(title = "客照关系", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CustomerPhoto customerPhoto)
    {
        List<CustomerPhoto> list = customerPhotoService.selectCustomerPhotoList(customerPhoto);
        ExcelUtil<CustomerPhoto> util = new ExcelUtil<CustomerPhoto>(CustomerPhoto.class);
        util.exportExcel(response, list, "客照关系数据");
    }

    /**
     * 获取客照关系详细信息
     */
    @ApiOperation("获取客照关系详细信息")
    @PreAuthorize("@ss.hasPermi('CustomerPhoto:photo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(customerPhotoService.selectCustomerPhotoById(id));
    }

    /**
     * 新增客照关系
     */
    @ApiOperation("新增客照关系")
    @PreAuthorize("@ss.hasPermi('CustomerPhoto:photo:add')")
    @Log(title = "客照关系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CustomerPhoto customerPhoto)
    {
        return toAjax(customerPhotoService.insertCustomerPhoto(customerPhoto));
    }

    /**
     * 修改客照关系
     */
    @ApiOperation("修改客照关系")
    @PreAuthorize("@ss.hasPermi('CustomerPhoto:photo:edit')")
    @Log(title = "客照关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CustomerPhoto customerPhoto)
    {
        return toAjax(customerPhotoService.updateCustomerPhoto(customerPhoto));
    }

    /**
     * 删除客照关系
     */
    @ApiOperation("删除客照关系")
    @PreAuthorize("@ss.hasPermi('CustomerPhoto:photo:remove')")
    @Log(title = "客照关系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(customerPhotoService.deleteCustomerPhotoByIds(ids));
    }
}
